<%# The license inside this block applies to this file.
	# Copyright 2020 Google Inc.
	# Licensed under the Apache License, Version 2.0 (the "License");
	# you may not use this file except in compliance with the License.
	# You may obtain a copy of the License at
	#
	#     http://www.apache.org/licenses/LICENSE-2.0
	#
	# Unless required by applicable law or agreed to in writing, software
	# distributed under the License is distributed on an "AS IS" BASIS,
	# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	# See the License for the specific language governing permissions and
	# limitations under the License.
-%>

// by default, we are not updating the member
if err := d.Set("api_updated_member", false); err != nil {
	return fmt.Errorf("Error setting api_updated_member: %s", err)
}

// iam_member is a generalized attribute, if the API can map it to a different member type on the backend, it will return
// the correct member_type in the response. If it cannot be mapped to a different member type, it will stay in iam_member.
if iamMemberProp != "" {
	member_type, member, err := resourceBigQueryDatasetAccessReassignIamMemberInNestedObjectList(d, meta, res["access"].([]interface{}))
	if err != nil {
		fmt.Println(err)
	}

	// if the member type changed, we set that member_type in state (it's already in the response) and we clear iam_member
	// and we set "api_updated_member" to true to acknowledge that we are making this change
	if member_type != "" {
		if err := d.Set(member_type, member.(string)); err != nil {
			return fmt.Errorf("Error setting member_type: %s", err)
		}
		if err := d.Set("iam_member", ""); err != nil {
			return fmt.Errorf("Error setting iam_member: %s", err)
		}
		if err := d.Set("api_updated_member", true); err != nil {
			return fmt.Errorf("Error setting api_updated_member: %s", err)
		}
	}
}